﻿Imports Control_Vuelos_BL

Public Class frmNotificar_Reserva
    Inherits frmBaseMantenimiento

    Private ReadOnly _Manifiesto As New ManifiestoBL()
    ReadOnly vAprobarBL As New AprobarBL()

    Private Sub frmNotificar_Reserva_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        AddHandler BarBtnGrabar.ItemClick, AddressOf prl_RegistroGrabar
        BarBtnGrabar.LargeGlyph = Control_Vuelos_GUI.My.Resources.Resources.Email
        BarBtnGrabar.Caption = "Enviar Email"
        BarBtnAgregar.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
        BarBtnModificar.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
        BarBtnEliminar.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
        BarBtnRefresh.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
        BarBtnImprimir.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
        BarBtnCancelar.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
        UcNotificar1.GridControl1.DataSource = _Manifiesto.pr_GetManifiesto("1")
        prl_Refresh()
    End Sub

    Public Sub prl_Refresh()
        UcNotificar1.GridControl1.DataSource = vAprobarBL.pr_CargarListaManifiestoporNotificar(p_coduser).Tables("Vuelos")
        UcNotificar1.GridView1.SetRowExpanded(-1, True, True)
    End Sub

    Private Sub prl_RegistroGrabar()
        Dim oDialogResult As System.Windows.Forms.DialogResult
        Using sfrmChk As New frmNotificarMessage() With {.Text = " Realizando la notificación de reservas "}
            sfrmChk.npMain.Text = " Se procederá a enviar un correo notificando al pasajero su próximo viaje."
            oDialogResult = sfrmChk.ShowDialog()
            If oDialogResult = System.Windows.Forms.DialogResult.OK Then
                Dim row As DataRow = TryCast(UcNotificar1.GridView1.GetDataRow(UcNotificar1.GridView1.GetSelectedRows()(0)), DataRow)
                If Not row Is Nothing Then
                    Dim scodviaje As String = row("CodViaje")
                    Dim sRelPasajeros As String = _Manifiesto.pr_NotificarPasajeroManifiesto(scodviaje)
                    If sRelPasajeros.Trim Is String.Empty Then
                        MsgBox("Hubo problemas en la notificación de viaje a los pasajeros del vuelo...", MsgBoxStyle.Critical, Text)
                    Else
                        Using sFrmChkPasajero As New frmNotificarMessage() With {.Text = " Personal notificado "}
                            sFrmChkPasajero.npMain.Text = String.Format(" Relación de pasajeros notificados {0}{0}{1}{0}", Constants.vbCrLf, sRelPasajeros)
                            sFrmChkPasajero.Height = 500
                            sFrmChkPasajero.cmdCancel.Enabled = False
                            sFrmChkPasajero.lbMensaje.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never
                            oDialogResult = sFrmChkPasajero.ShowDialog()
                        End Using
                    End If
                End If
            End If
        End Using
    End Sub

End Class